package cn.chengpengper.shortlink.exception;

import cn.chengpengper.shortlink.enums.BizCodeEnum;
import lombok.Data;

/**
 * @author huchengpeng
 * @version 1.0.0
 * @date 2023/6/18 20:46
 * @description 自定义异常
 */
@Data
public class BizException extends RuntimeException {

    private static final long serialVersionUID = 3216317101385336575L;
    private int code;

    private String msg;

    public BizException(Integer code, String message) {
        super(message);
        this.code = code;
        this.msg = message;
    }

    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
    }
}
